/**
 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.portlet.donggoi.model;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.BaseModel;
import com.liferay.portal.model.impl.BaseModelImpl;

import com.portlet.donggoi.service.ClpSerializer;
import com.portlet.donggoi.service.chiTietQTDongGoiLocalServiceUtil;

import java.io.Serializable;

import java.lang.reflect.Method;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Thi
 */
public class chiTietQTDongGoiClp extends BaseModelImpl<chiTietQTDongGoi>
	implements chiTietQTDongGoi {
	public chiTietQTDongGoiClp() {
	}

	public Class<?> getModelClass() {
		return chiTietQTDongGoi.class;
	}

	public String getModelClassName() {
		return chiTietQTDongGoi.class.getName();
	}

	public String getPrimaryKey() {
		return _maChiTietQT;
	}

	public void setPrimaryKey(String primaryKey) {
		setMaChiTietQT(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return _maChiTietQT;
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey((String)primaryKeyObj);
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("maChiTietQT", getMaChiTietQT());
		attributes.put("tenCongDoan", getTenCongDoan());
		attributes.put("cachThucHien", getCachThucHien());
		attributes.put("kiemTraThucHien", getKiemTraThucHien());
		attributes.put("tanSuat", getTanSuat());
		attributes.put("maQuyTrinh", getMaQuyTrinh());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		String maChiTietQT = (String)attributes.get("maChiTietQT");

		if (maChiTietQT != null) {
			setMaChiTietQT(maChiTietQT);
		}

		String tenCongDoan = (String)attributes.get("tenCongDoan");

		if (tenCongDoan != null) {
			setTenCongDoan(tenCongDoan);
		}

		String cachThucHien = (String)attributes.get("cachThucHien");

		if (cachThucHien != null) {
			setCachThucHien(cachThucHien);
		}

		String kiemTraThucHien = (String)attributes.get("kiemTraThucHien");

		if (kiemTraThucHien != null) {
			setKiemTraThucHien(kiemTraThucHien);
		}

		String tanSuat = (String)attributes.get("tanSuat");

		if (tanSuat != null) {
			setTanSuat(tanSuat);
		}

		String maQuyTrinh = (String)attributes.get("maQuyTrinh");

		if (maQuyTrinh != null) {
			setMaQuyTrinh(maQuyTrinh);
		}
	}

	public String getMaChiTietQT() {
		return _maChiTietQT;
	}

	public void setMaChiTietQT(String maChiTietQT) {
		_maChiTietQT = maChiTietQT;

		if (_chiTietQTDongGoiRemoteModel != null) {
			try {
				Class<?> clazz = _chiTietQTDongGoiRemoteModel.getClass();

				Method method = clazz.getMethod("setMaChiTietQT", String.class);

				method.invoke(_chiTietQTDongGoiRemoteModel, maChiTietQT);
			}
			catch (Exception e) {
				throw new UnsupportedOperationException(e);
			}
		}
	}

	public String getTenCongDoan() {
		return _tenCongDoan;
	}

	public void setTenCongDoan(String tenCongDoan) {
		_tenCongDoan = tenCongDoan;

		if (_chiTietQTDongGoiRemoteModel != null) {
			try {
				Class<?> clazz = _chiTietQTDongGoiRemoteModel.getClass();

				Method method = clazz.getMethod("setTenCongDoan", String.class);

				method.invoke(_chiTietQTDongGoiRemoteModel, tenCongDoan);
			}
			catch (Exception e) {
				throw new UnsupportedOperationException(e);
			}
		}
	}

	public String getCachThucHien() {
		return _cachThucHien;
	}

	public void setCachThucHien(String cachThucHien) {
		_cachThucHien = cachThucHien;

		if (_chiTietQTDongGoiRemoteModel != null) {
			try {
				Class<?> clazz = _chiTietQTDongGoiRemoteModel.getClass();

				Method method = clazz.getMethod("setCachThucHien", String.class);

				method.invoke(_chiTietQTDongGoiRemoteModel, cachThucHien);
			}
			catch (Exception e) {
				throw new UnsupportedOperationException(e);
			}
		}
	}

	public String getKiemTraThucHien() {
		return _kiemTraThucHien;
	}

	public void setKiemTraThucHien(String kiemTraThucHien) {
		_kiemTraThucHien = kiemTraThucHien;

		if (_chiTietQTDongGoiRemoteModel != null) {
			try {
				Class<?> clazz = _chiTietQTDongGoiRemoteModel.getClass();

				Method method = clazz.getMethod("setKiemTraThucHien",
						String.class);

				method.invoke(_chiTietQTDongGoiRemoteModel, kiemTraThucHien);
			}
			catch (Exception e) {
				throw new UnsupportedOperationException(e);
			}
		}
	}

	public String getTanSuat() {
		return _tanSuat;
	}

	public void setTanSuat(String tanSuat) {
		_tanSuat = tanSuat;

		if (_chiTietQTDongGoiRemoteModel != null) {
			try {
				Class<?> clazz = _chiTietQTDongGoiRemoteModel.getClass();

				Method method = clazz.getMethod("setTanSuat", String.class);

				method.invoke(_chiTietQTDongGoiRemoteModel, tanSuat);
			}
			catch (Exception e) {
				throw new UnsupportedOperationException(e);
			}
		}
	}

	public String getMaQuyTrinh() {
		return _maQuyTrinh;
	}

	public void setMaQuyTrinh(String maQuyTrinh) {
		_maQuyTrinh = maQuyTrinh;

		if (_chiTietQTDongGoiRemoteModel != null) {
			try {
				Class<?> clazz = _chiTietQTDongGoiRemoteModel.getClass();

				Method method = clazz.getMethod("setMaQuyTrinh", String.class);

				method.invoke(_chiTietQTDongGoiRemoteModel, maQuyTrinh);
			}
			catch (Exception e) {
				throw new UnsupportedOperationException(e);
			}
		}
	}

	public BaseModel<?> getchiTietQTDongGoiRemoteModel() {
		return _chiTietQTDongGoiRemoteModel;
	}

	public void setchiTietQTDongGoiRemoteModel(
		BaseModel<?> chiTietQTDongGoiRemoteModel) {
		_chiTietQTDongGoiRemoteModel = chiTietQTDongGoiRemoteModel;
	}

	public Object invokeOnRemoteModel(String methodName,
		Class<?>[] parameterTypes, Object[] parameterValues)
		throws Exception {
		Object[] remoteParameterValues = new Object[parameterValues.length];

		for (int i = 0; i < parameterValues.length; i++) {
			if (parameterValues[i] != null) {
				remoteParameterValues[i] = ClpSerializer.translateInput(parameterValues[i]);
			}
		}

		Class<?> remoteModelClass = _chiTietQTDongGoiRemoteModel.getClass();

		ClassLoader remoteModelClassLoader = remoteModelClass.getClassLoader();

		Class<?>[] remoteParameterTypes = new Class[parameterTypes.length];

		for (int i = 0; i < parameterTypes.length; i++) {
			if (parameterTypes[i].isPrimitive()) {
				remoteParameterTypes[i] = parameterTypes[i];
			}
			else {
				String parameterTypeName = parameterTypes[i].getName();

				remoteParameterTypes[i] = remoteModelClassLoader.loadClass(parameterTypeName);
			}
		}

		Method method = remoteModelClass.getMethod(methodName,
				remoteParameterTypes);

		Object returnValue = method.invoke(_chiTietQTDongGoiRemoteModel,
				remoteParameterValues);

		if (returnValue != null) {
			returnValue = ClpSerializer.translateOutput(returnValue);
		}

		return returnValue;
	}

	public void persist() throws SystemException {
		if (this.isNew()) {
			chiTietQTDongGoiLocalServiceUtil.addchiTietQTDongGoi(this);
		}
		else {
			chiTietQTDongGoiLocalServiceUtil.updatechiTietQTDongGoi(this);
		}
	}

	@Override
	public chiTietQTDongGoi toEscapedModel() {
		return (chiTietQTDongGoi)ProxyUtil.newProxyInstance(chiTietQTDongGoi.class.getClassLoader(),
			new Class[] { chiTietQTDongGoi.class },
			new AutoEscapeBeanHandler(this));
	}

	public chiTietQTDongGoi toUnescapedModel() {
		return this;
	}

	@Override
	public Object clone() {
		chiTietQTDongGoiClp clone = new chiTietQTDongGoiClp();

		clone.setMaChiTietQT(getMaChiTietQT());
		clone.setTenCongDoan(getTenCongDoan());
		clone.setCachThucHien(getCachThucHien());
		clone.setKiemTraThucHien(getKiemTraThucHien());
		clone.setTanSuat(getTanSuat());
		clone.setMaQuyTrinh(getMaQuyTrinh());

		return clone;
	}

	public int compareTo(chiTietQTDongGoi chiTietQTDongGoi) {
		String primaryKey = chiTietQTDongGoi.getPrimaryKey();

		return getPrimaryKey().compareTo(primaryKey);
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}

		if (!(obj instanceof chiTietQTDongGoiClp)) {
			return false;
		}

		chiTietQTDongGoiClp chiTietQTDongGoi = (chiTietQTDongGoiClp)obj;

		String primaryKey = chiTietQTDongGoi.getPrimaryKey();

		if (getPrimaryKey().equals(primaryKey)) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return getPrimaryKey().hashCode();
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(13);

		sb.append("{maChiTietQT=");
		sb.append(getMaChiTietQT());
		sb.append(", tenCongDoan=");
		sb.append(getTenCongDoan());
		sb.append(", cachThucHien=");
		sb.append(getCachThucHien());
		sb.append(", kiemTraThucHien=");
		sb.append(getKiemTraThucHien());
		sb.append(", tanSuat=");
		sb.append(getTanSuat());
		sb.append(", maQuyTrinh=");
		sb.append(getMaQuyTrinh());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(22);

		sb.append("<model><model-name>");
		sb.append("com.portlet.donggoi.model.chiTietQTDongGoi");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>maChiTietQT</column-name><column-value><![CDATA[");
		sb.append(getMaChiTietQT());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>tenCongDoan</column-name><column-value><![CDATA[");
		sb.append(getTenCongDoan());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>cachThucHien</column-name><column-value><![CDATA[");
		sb.append(getCachThucHien());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>kiemTraThucHien</column-name><column-value><![CDATA[");
		sb.append(getKiemTraThucHien());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>tanSuat</column-name><column-value><![CDATA[");
		sb.append(getTanSuat());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>maQuyTrinh</column-name><column-value><![CDATA[");
		sb.append(getMaQuyTrinh());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private String _maChiTietQT;
	private String _tenCongDoan;
	private String _cachThucHien;
	private String _kiemTraThucHien;
	private String _tanSuat;
	private String _maQuyTrinh;
	private BaseModel<?> _chiTietQTDongGoiRemoteModel;
}